package com.t235.gc.device.service.impl;

import com.t235.gc.entity.DeviceVersion;
import com.t235.gc.dao.DeviceVersionDao;
import com.t235.gc.device.service.DeviceVersionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 设备版本表(DeviceVersion)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:23
 */
@Service("deviceVersionService")
public class DeviceVersionServiceImpl implements DeviceVersionService {
    @Resource
    private DeviceVersionDao deviceVersionDao;

    /**
     * 通过ID查询单条数据
     *
     * @param versionid 主键
     * @return 实例对象
     */
    @Override
    public DeviceVersion queryById(Long versionid) {
        return this.deviceVersionDao.queryById(versionid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<DeviceVersion> queryAllByLimit(int offset, int limit) {
        return this.deviceVersionDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param deviceVersion 实例对象
     * @return 实例对象
     */
    @Override
    public DeviceVersion insert(DeviceVersion deviceVersion) {
        this.deviceVersionDao.insert(deviceVersion);
        return deviceVersion;
    }

    /**
     * 修改数据
     *
     * @param deviceVersion 实例对象
     * @return 实例对象
     */
    @Override
    public DeviceVersion update(DeviceVersion deviceVersion) {
        this.deviceVersionDao.update(deviceVersion);
        return this.queryById(deviceVersion.getVersionid());
    }

    /**
     * 通过主键删除数据
     *
     * @param versionid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long versionid) {
        return this.deviceVersionDao.deleteById(versionid) > 0;
    }
}
